//
//  ShoppingCollectViewCell.m
//  JewelryStore
//
//  Created by apple on 2016/12/20.
//  Copyright © 2016年 com. All rights reserved.
//

#import "ShoppingCollectViewCell.h"
#import "ShopingTwoCollectionViewCell.h"

#define COLLECTVIEWITEM @"item"

@interface ShoppingCollectViewCell ()<UICollectionViewDelegate, UICollectionViewDataSource>
@property (nonatomic, copy) NSArray *model;
@end

@implementation ShoppingCollectViewCell

- (void)awakeFromNib
{
    [super awakeFromNib];
    
    [self cofigureCollectView];

}

- (void)cofigureCollectView
{
    UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
    
    layout.itemSize = CGSizeMake(SCREEN_WIDTH/2.01, SCREEN_WIDTH/1.8);

    layout.minimumLineSpacing = 1;
    
    layout.minimumInteritemSpacing = 1;
    
    self.collectView.collectionViewLayout = layout;
    
    self.collectView.delegate = self;
    
    self.collectView.dataSource = self;
    
    self.collectView.bounces = NO;
    
    self.collectView.scrollEnabled = NO;
        
    [self.collectView registerNib:[UINib nibWithNibName:@"ShopingTwoCollectionViewCell" bundle:nil] forCellWithReuseIdentifier:COLLECTVIEWITEM];
}

#pragma mark - dataSource

- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
    return self.model.count;
}

- (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    ShopingTwoCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:COLLECTVIEWITEM forIndexPath:indexPath];
    
    return cell;
}

#pragma mark - delegate

- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
    TT_Log(@"itemClick");
    
    self.block(indexPath);
}

#pragma mark - lazy

- (NSArray *)model
{
    if (!_model) {
        
        _model = @[@"", @"", @"", @"", @""];
    }
    return _model;
}
@end
